package com.project.webpage.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.project.webpage.entity.UserXl;
import com.project.webpage.entity.Yhxx;
import com.project.webpage.mapper.UserXlMapper;
import com.project.webpage.service.UserService;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Resource
    private UserXlMapper userXlMapper;

    @Override
    @DS("master")
    public List<UserXl> getXlList(String uid) {
        Example example = new Example(UserXl.class);
        Example.Criteria c = example.createCriteria();
        c.andEqualTo("uid", uid);
        return userXlMapper.selectByExample(example);
    }

    @Override
    @DS("master")
    public void updateXlList(List<UserXl> list) {
        userXlMapper.deleteByUid(list.get(0));
        for (UserXl userXl : list) {
            userXlMapper.insertSelective(userXl);
        }
    }
}
